<template>
	<view class="My-Community" v-if="MyCommitData">
		<z-paging ref="paging" v-model="MyCommitData" @query="queryList" 
		:loading-more-enabled="false">
			<template #refresher="{refresherStatus}">
				<!-- 此处的custom-refresh为demo中自定义的组件，非z-paging的内置组件，请在实际项目中自行创建。这里插入什么view，下拉刷新就显示什么view -->
				<custom-refresher :status="refresherStatus" />
			</template>
				<PublicCommunityCardVue class="card-box" :cardData="MyCommitData"></PublicCommunityCardVue>
		</z-paging>
	</view>
	<NoDataVue v-else message="还没有发布图库哦 ~" addDataText="立即发布吧!" toPageUrl="/pages/community/publishPage"></NoDataVue>
</template>

<script setup>
	import NoDataVue from '@/components/NoData.vue';
	import PublicCommunityCardVue from '../MyCommunity/components/PublicCommunityCard.vue';
	import {ref} from 'vue';
	import {onShow} from '@dcloudio/uni-app';
	import {GetMyCommit} from '@/config/API/commit';
	const MyCommitData = ref()
	const paging = ref(null); // 用于控制z-paging
	onShow(async () => {
		try {
			const resData = await GetMyCommit();
			MyCommitData.value = resData.data
			console.log('resData.value我发布的图库', MyCommitData.value);
		} catch (error) {
			console.error('获取地址数据出错：', error);
		}
	});
	// 分页查询函数
	const queryList = async (pageNo, pageSize) => {
		if (MyCommitData.value) {
			paging.value.complete(MyCommitData.value); // 数据加载完成
		} else {
			paging.value.complete(false); // 无数据
		}
	};
</script>

<style lang="scss" scoped>
	.My-Community{
		width: 100%;
		min-height: 100vh;
		padding: 30rpx;
		box-sizing: border-box;
		.card-box{
			display: flex;
			flex-direction: column;
			gap: 80rpx;
		}
	}
</style>


<!-- <template>
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
	@scrolltolower="lower" @scroll="scroll">
			<CommitCardVue @openMsg='openMsg' :cardData='commitData'></CommitCardVue>
			<view class="heightboxall"></view>
	</scroll-view>
	<morePoupoVue @openit='openit' @deleteIt='deleteIt' ref="isMore"></morePoupoVue>
	<besureDeleteVue @submitSignin='submitSignin' ref="isOpen"></besureDeleteVue>
</template>

<script setup>
	import besureDeleteVue from './components/besureDelete.vue';
	import morePoupoVue from './components/morePoupo.vue';
	import { onMounted, ref } from 'vue'
	import CommitCardVue from '/pages/community/components/CommitCard.vue';
	import { GetMyCommit } from '@/config/API/commit';
	import {onPageShow} from '@dcloudio/uni-app'
	const PageDataStrat = ref(1)
	const commitData = ref()
	const PageSize = ref(5)
	const isOpen = ref(null)
	const isMore = ref(null)
	const openit = (item) =>{
		console.log('打开',item)
		uni.navigateTo({
			url:`/pages/community/addCard?item=`+JSON.stringify(item)
		})
	}
	const deleteIt = (item) =>{
		console.log('删除',item)
		isOpen.value.showPopup(item)
	}
	const submitSignin = (itemFrom) =>{
		console.log('选中的',itemFrom)
		commitData.value = commitData.value.filter(ite=>{
			return ite.CommunityID!==itemFrom.CommunityID
		})
		console.log('选中的',commitData.value)
	}
	const openMsg =(item)=>{
		console.log('左上角',isMore.value)
		isMore.value.showPopup(item)
	}
	
	onPageShow(async()=>{
		const data = await GetMyCommit()
		commitData.value = data.data.map(item => ({
		        ...item,
		        imgList: item.img_list ? item.img_list.split(',') : [] ,// 添加检查
					isMy:true
		      }));
		console.log('社区数据==》》',commitData.value)
	
	})
</script>

<style lang="scss" scoped>
	@import url('../../pages/community/css/commitCss.css')
</style> -->
